from main.models import Type, Subtype, Color, Set, Tag, Card, CardType, CardSubtype, CardTag, Image, CardPrint
from django.contrib import admin

class CardTypeInline(admin.TabularInline):
    model = CardType
    extra = 1

class CardSubtypeInline(admin.TabularInline):
    model = CardSubtype
    extra = 1

class CardTagInline(admin.TabularInline):
    model = CardTag
    extra = 1

class CardAdmin(admin.ModelAdmin):
    inlines = [CardTypeInline, CardSubtypeInline, CardTagInline]
    fieldsets = (
        (None, {
            'fields': ('name', 'cost')
        }),
        ('Rules text', {
            'classes': ('collapse',),
            'fields': ('rules_text',)
        }),
        ('Flavor text', {
            'classes': ('collapse',),
            'fields': ('flavor_text',)
        }),
        ('Power/Toughness', {
            'classes': ('collapse',),
            'fields': ('power', 'toughness')
        }),
    )

class CardInline(admin.TabularInline):
    model = Card
    extra = 1

class SetInline(admin.TabularInline):
    model = Set
    extra = 1

admin.site.register(Type)
admin.site.register(Subtype)
admin.site.register(Color)
admin.site.register(Set)
admin.site.register(Tag)
admin.site.register(Card, CardAdmin)
admin.site.register(CardType)
admin.site.register(CardSubtype)
admin.site.register(CardTag)
admin.site.register(Image)
admin.site.register(CardPrint)

